package com.lch.designpattern.flyweight;

import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: liuchenhui
 * @create: 2020-03-08 14:52
 **/
public class ConectionPool {

    private Vector<Object> pool = new Vector<>();

    public synchronized Object getConection() {
        if (pool.size() > 0) {
            Object o = pool.get(0);
            pool.remove(o);
            return o;
        }
        Object obj = new Object();
        pool.add(obj);
        return obj;
    }

    public void remove(Object obj) {
        pool.remove(obj);
    }

    public void relase(Object object) {
        pool.add(object);
    }
}
